<template>
  <!-- 1.2动态绑定style样式 -->
  <div class="my-header" :style="{ background, color }">{{ title }}</div>
</template>

<script>
// 1.0头部动态生成，可以在父组件内更改值
// 1.1父组件传入数据，子组件通过props属性接收
export default {
  props: {
    background: String,
    color: {
      type: String,
      default: "#fff",
    },
    title: {
      type: String,
      required: true,
    },
  },
};
</script>

<style lang="less" scoped>
.my-header {
  height: 45px;
  line-height: 45px;
  text-align: center;
  background-color: #1d7bff;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2;
}
</style>